<?php
require_once 'SpotLight/core/system/Loader.class.php';
Session::start ();
require_once 'SpotLight/configs/config.php';
$s = microtime ( TRUE );

//Benchmark::startDev ( 'controller' );

try {

   new ConfigReader ( );
   new SpotLight ( Request::dispatchURI () );
   
   #TODO: refactor this:->
} catch ( ConfigException $e ) {
   die ( ExceptionPage::getExceptionPage ( $e, 'Check spotlight.xml config file.' ) );
} catch ( ActionInvokeException $e ) {
   if (Session::getSystemValue ( 'dev', false ) == true)
      die ( ExceptionPage::getExceptionPage ( $e, 'Controller processing...' ) );
   else
      header ( "HTTP/1.0 404 Not Found" );
}

$e = microtime ( TRUE );
//Benchmark::stopDev ( 'controller' );
Benchmark::saveRes ( date ( $e - $s ) . "\t" . $_SERVER ['REQUEST_URI'] );
//Benchmark::getDev();
?>
